<%@page import="java.util.*"%>
<%@page import="com.ks.sgms.dao.*" %>
<%@page import="com.ks.sgms.entity.*" %>
<%@ page language="java" contentType="text/html; charset=utf-8"
    pageEncoding="utf-8"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>学院专业管理</title>
</head>
<%
	request.setCharacterEncoding("UTF-8");
	DepartmentDao dao = new DepartmentDao();
	List<Department> list = dao.getAll();
%>
<body>
	<div>
		<h1>学院专业管理</h1>
		<div class="box">
			<a href="department-insert.jsp" style="width:50px">
				<button>添加<tton>
			</a>
		</div>	
		<table>
			<tr>
				<td colspan="5">数据库中数据如下所示:</td>
			</tr>
			<tr>
				<td>学院</td>
				<td>专业</td>
				<td>总人数</td>
				<td colspan="2">操作</td>
			</tr>
			
			<%if(list!=null)
				for(int i = 0;i < list.size();i++){ %>
				<tr>
					<td><%=list.get(i).department_name%></td>
					<td><%=list.get(i).major_name%></td>
					<td><%=list.get(i).allPersonNumber%></td>
					<td><a href="department-update.jsp?major_id=<%=list.get(i).major_id%>">
						<button>修改</button>
					</a></td>
					<td><a href="deleteDepartment?major_id_del=<%=list.get(i).major_id%>">
						<button>删除</button>
					</a></td>
				</tr>
			<%} %>
		</table>	
	</div>
</body>
<style type="text/css">
	div {
		margin: 0 auto;
		width: 80%;
	}
	
	table {
		border: 2px solid;
	}
	
	td {
		border: 1px solid;
		text-align: center;
		width: 200px;
		height: 30px;
	}
	.box{
		display: flex;
		flex-direction: row;
	}
</style>
</html>